<template>
  <!-- <div class="dashboard-container" style="text-align: center">
    <component :is="currentRole" />
    <p>欢迎来到中模云人事系统</p>
    <p>首页正在开发中，请耐心等待</p>
  </div> -->
  <MyDashboard />
</template>
<script>
import { mapGetters } from 'vuex'
import adminDashboard from './admin'
import editorDashboard from './editor'
import { userReminder } from '@/api/basic'
import { userReminderHome } from '@/api/v2/reminder'
import MyDashboard from './Dashboard'

export default {
  name: 'Dashboard',
  components: { adminDashboard, editorDashboard, MyDashboard },
  data() {
    return {
      currentRole: 'adminDashboard'
    }
  },
  computed: {
    ...mapGetters(['roles'])
  },
  created() {
    if (!this.roles.includes('admin')) {
      this.currentRole = 'editorDashboard'
    }
    this.getdata()
  },
  methods: {
    getdata() {
      const h = this.$createElement
      userReminderHome()
        .then((res) => {
          if (res.data.reminder) {
            this.$notify.info({
              title: '时间提醒',
              duration: 0,
              message: h('div', { class: 'message' }, [
                h('div', { class: 'btnList' }, [
                  h(
                    'span',
                    null,
                    `有员工合同到期，请及时处理`
                  ),
                  h(
                    'span',
                    {
                      class: 'later',
                      on: {
                        click: () => {
                          this.doSomeThing(res.data.type_id)
                        }
                      }
                    },
                    '点击查看'
                  )
                ])
              ])
            })
          }
        })
        .catch((err) => {
          console.log(err)
        })
    },
    doSomeThing(item) {
      this.$router.push(`/reminder/reminderList?type=${item}`)
    }
  }
}
</script>
<style lang="scss">
.later {
  color: #1890ff;
  margin-left: 10px;
  cursor: pointer;
}
</style>
